home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BMUG Revelations
/
BMUG Revelations.toast
/
Programming
/
Programming Languages
/
XLisp 2.1e3
/
lisp
/
dragon.lsp
< prev
next >
Wrap
Lisp/Scheme
|
1993-05-18
|
1KB
|
40 lines
; dragon.lsp for MacXLisp 2.1e by Tom Almy and Brian Kendig
;
; An Nth-order dragon curve using turtle drawing routines.
; Originally from Byte (April 1986), converted to xlisp
; by Peter Ashwood-Smith, modified by Tom Almy and Brian Kendig.
;
; Note that you have to have turtle.lsp loaded for this to work.
; And you might want to press Command-Period to stop the program
; when it starts drawing beyond the window where you can't see it.
;
; P.S - This dragon is nicknamed "spot".
;#-:turtle (load "turtle")
(defvar *StepSize* 1)
(defun Dragon (sign level)
(if (zerop level)
(TurtleForward *StepSize*)
(progn
(setq level (1- level))
(TurtleRight (* 45 sign))
(Dragon -1 level)
(TurtleLeft (* 90 sign))
(Dragon 1 level)
(TurtleRight (* 45 sign)))))
(defun DragonCurve (n m)
(setq *StepSize* m) ; *StepSize* is global variable
(TurtleInit)
(color 0 40000 0)
(TurtleCenter)
(TurtleGoto 50 50)
(TurtleRight 30) ; angle the serpent a bit
(Dragon 1 n)
(gc))
(print "Try (DragonCurve 14 3)")